import React, { Component } from 'react';

class Notfound extends Component {

  state = {
    time: 3,
    timeer: null
  }

  componentDidMount() {
    this.state.timeer = setInterval(() => {
      if (this.state.time === 0) {
        // this.props.history.push('/')
        location.href = '/'
      }
      this.setState(state => {
        return {
          time: state.time - 1
        }
      })
    }, 1000);
  }

  componentWillUnmount() {
    clearInterval(this.state.timeer)
  }

  render() {
    return (
      <div>
        <h1>页面丢了</h1>
        <hr />
        <h3>{this.state.time}</h3>
      </div>
    );
  }
}

export default Notfound;
